/**
 * @author Liu Awen Email:willowawen@gmail.com
 * @create 2020-05-16
 */
//1、求三角形面积
public class Triangle {
    private double firstEdge;
    private double secondEdge;
    private double thirdEdge;

    public boolean isTriangle() {
        if ((firstEdge + secondEdge) > thirdEdge && (firstEdge + thirdEdge) > secondEdge && (secondEdge + thirdEdge) > firstEdge) {
            return true; //如果符合三角形成立的条件，返回true
        }
        return false;
    }

    public void squaring() {
        double p = (firstEdge + secondEdge + thirdEdge);
        p = p / 2;
        double area = Math.sqrt(p * (p - firstEdge) * (p - secondEdge) * (p - thirdEdge));
        System.out.println("三角形的面积为：" + area);
    }


    public static void main(String[] args) {
        Triangle triangle = new Triangle();
        triangle.firstEdge = 30;
        triangle.secondEdge = 40;
        triangle.thirdEdge = 50;
        if (triangle.isTriangle()) {
            System.out.println("这三边满足三角形");
        } else {
            System.out.println("这三边不构成三角形");
        }
        triangle.squaring();
    }
}
